﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectNocturnalFool
{

    public enum Label_Type
    {
        title,
        message
    }


    class LabelControl : UserControl
    {

        public SpriteFont font;
        public string message = "";

        private Label_Type _type;
        public Label_Type type
        {
            get { return _type; }
            set
            {
                _type = value;
                switch (value)
                {
                    case Label_Type.title:
                        bgTexture = TacticsGame.Instance.Content.Load<Texture2D>(Constants.TextureLabelTitle);
                        width = bgTexture.Width;
                        height = bgTexture.Height;        
                        break;
                    case Label_Type.message:
                        bgTexture = TacticsGame.Instance.Content.Load<Texture2D>(Constants.TextureBlank);
                        Vector2 size = font.MeasureString(message);
                        width = (int)size.X;
                        height = (int)size.Y;
                        break;

                }
            }
        }

        public override void LoadContent()
        {
            base.LoadContent();
            font = TacticsGame.Instance.gameFont;
            depth = ControlDepth.NonDrag;

        }

        public override void Draw(GameTime gameTime)
        {
            TacticsGame.Instance.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone);
            Rectangle targetRect = new Rectangle(x, y, width, height);

            TacticsGame.Instance.spriteBatch.Draw(bgTexture, 
                                                  targetRect, 
                                                  null, 
                                                  Color.White, 
                                                  0, 
                                                  Vector2.Zero, 
                                                  SpriteEffects.None, 
                                                  0);

            TacticsGame.Instance.spriteBatch.DrawString(font,
                                            message,
                                            new Vector2(x, y),
                                            Color.Black,
                                            0.0f,
                                            new Vector2(0, 0),
                                            Constants.FontScale,
                                            SpriteEffects.None,
                                            0);

            TacticsGame.Instance.spriteBatch.End();
        }

    }
}
